<?php
/*
if not connector
	ask conn
	create connector
	connect
	if not sitegeist
		create db
		create geist

else
	
		
*/
//session_start();
if(isset($_POST['host'])&&isset($_POST['port'])&&isset($_POST['dbu'])&&isset($_POST['dbp'])){
/*
$_SESSION['host']=$_POST['host'];
$_SESSION['port']=$_POST['port'];
$_SESSION['dbu']=$_POST['dbu'];
$_SESSION['dbp']=$_POST['dbp'];
*/

$host=$_POST['host']; $port=$_POST['port']; $dbu=$_POST['dbu']; $dbp=$_POST['dbp'];

file_put_contents('plugin/base/.db/connect.php',
"<?php
\$host='$host';
\$port='$port';
\$db='sitegeist';
\$dbu='$dbu';
\$dbp='$dbp';
\$db=new PDO(\"mysql:host=\$host;port=\$port;dbname=\$db\",\$dbu,\$dbp,array(
	PDO::MYSQL_ATTR_INIT_COMMAND=>\"SET NAMES utf8\" 
));
\$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
//\$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY:: ?? );
?>");

unset($_POST['host']); unset($_POST['port']); unset($_POST['dbu']); unset($_POST['dbp']);

include'plugin/base/.db/connect.php';
$database="sitegeist";
include'plugin/base/.db/exists/database.php';
if($database){
	echo'geist';
}
else{
	include'install.php';
}



header('Location: index1.php');
}
else{ 
?><form name="dbc" method="post" action="firstuser.php">
<h4>MySQL</h4>
login information of your database server
<div><label>host name</label><input name="host" value="localhost"/></div>
<div><label>port number</label><input name="port" value="3307"/></div>
<div><label>user name</label><input name="dbu" value="root"/></div>
<div><label>password</label><input name="dbp" value="usbw"/></div>
<h4>sitegeist</h4>
choose these yourself
<div><label>user name</label><input name="user" value="admin"/></div>
<div><label>password</label><input name="password" value="nimda"/></div>
<h5><input type="submit" value="submit"/></h5>
</form><?php
} ?>